<%@ page contentType="text/html; charset=utf-8" language="java"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系统用户</title>
<link type="text/css" rel="stylesheet" href="/commonSys/css/index.css" />
<script language="javascript" src="/commonSys/js/jquery-1.7.1.min.js"></script>
<script language="javascript" src="/commonSys/js/lightbox/jquery.lightbox_me.js"></script>
<script language="javascript" src="/commonSys/js/validate.js"></script>
</head>
<body>
 <div class="show_main2">
            <div class="title">角色设置</div>
            <div class="content">
              <s:form id="form"  action="saveRole" theme="simple">  
				<s:hidden name="vo.id" id="vo.id"></s:hidden>
				<ul>
					<s:iterator value="userRoleList" status="st">
					<li>	
						<input type="checkbox" <s:if test='selected == "1"'>checked="checked"</s:if> name="role_<s:property value="#st.getIndex()"/>"  value="<s:property value="roleId"/>">
						<s:property value="roleName"/><br/>
					</li>
					</s:iterator>	
				</ul>
      		  </s:form>
            </div>
            <div class="bottom">
                <span class="default_btn_1" id="insert-update-but"  onclick="saveUserRole();"   >确定</span>&nbsp;&nbsp;&nbsp;&nbsp;
                <span class="default_btn_1 close" onclick="closeWin();">取消</span>
            </div>
</div>
</body>
<script language="javascript">

	function getCheckBoxValue(para) {
    	var str = "";
    	$("input[name*="+para+"]:checked").each(function(index) {
   			str += $(this).val()+',';
    	});
    	
    	if(str.lastIndexOf(',')==str.length-1){
				str = str.substring(0,(str.length-1));
		}
    	
		return str;    
    }
	
	var id = '<%=request.getParameter("id") %>';
	
	function saveUserRole(){
		var url = "/commonSys/manager/role/updateUserRole.shtml";
		var param = {'id':id,'roleIds':getCheckBoxValue("role_")};
		$.post(url 
			,param 
				,function(rs) {
					if(rs.code==0){
						alert('操作成功');
						closeWin();
					}else{
						alert('操作失败');
						closeWin();
					}
				}
		   ,'json');
	}
	
	function closeWin(){
		window.close();
	}


</script>

</html>

